package lyq.spec.edu.week12_home01;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class WeChatAdpater3 extends RecyclerView.Adapter<WeChatAdpater3.ViewHolder>{

        private List<Wechat3> mWeChatList;

        static class ViewHolder extends RecyclerView.ViewHolder{

            ImageView imageMPId;

            TextView MoviePark;



            public ViewHolder(View view) {

                super(view);

                imageMPId = (ImageView) view.findViewById(R.id.wechat3_image);

                MoviePark = (TextView) view.findViewById(R.id.wechat3_MoviePark);

            }

        }



        public WeChatAdpater3(List<Wechat3> mWeChatList) {

            this.mWeChatList = mWeChatList;

        }

    //加载item 的布局  创建ViewHolder实例

    @Override

    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.wechat_third,parent,false);

        ViewHolder holder = new ViewHolder(view);

        return holder;

    }


    //对RecyclerView子项数据进行赋值

    @Override

    public void onBindViewHolder(ViewHolder holder, int position) {

        Wechat3 wechat3 = mWeChatList.get(position);

        holder.MoviePark.setText(wechat3.getMoviePark());

        holder.imageMPId.setImageResource(wechat3.getImageMPId());

    }


    //返回子项个数

    @Override

    public int getItemCount() {

        return mWeChatList.size();

    }

}


